<?php

class View_Helper_Media extends Zend_View_Helper_Abstract
{	
	public function media($string)
	{
		$array = explode('.', $string);
		if (count($array) == 2) {
			$prefix = '';
			$name = $array[0];
			$extension = $array[1];
		} elseif (count($array) == 3) {
			$prefix = $array[0] . '/';
			$name = $array[0] . '.' . $array[1];
			$extension = $array[2];
		}
		
		if ($extension == 'js') {
			$path = "/javascript/{$prefix}{$name}.$extension";
			return "<script type='text/javascript' src='$path'></script>\n";
		}
		
		if ($extension == 'css') {
			$path = "/style/{$prefix}{$name}.$extension";
			return "<link rel='stylesheet' href='$path' type='text/css' />\n";
		}
		
		return $string;
	}
}